package com.jwell.cargoapp.ui.dialog

import android.app.Dialog
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.Window
import com.jwell.panrank.R
import kotlinx.android.synthetic.main.dialog_load_layout.view.*

/**
 * Created by Administrator on 2017/7/24.
 *
 */
class LoadingDialog {
    class Builder(private val context: Context?) {
        private val themid = 0
        private var describle: String? = ""
        private var isOutTouch = false

        fun setDescrible(describle: String): Builder {
            this.describle = describle
            return this
        }

        fun setOutouch(outouch: Boolean): Builder {
            this.isOutTouch = outouch
            return this
        }

        fun creat(): Dialog? {
            if (context == null) {
                throw IllegalArgumentException("Dialog context is null!")
            }
            val dialog = Dialog(context, R.style.dialog1)
            val contentView = LayoutInflater.from(context).inflate(R.layout.dialog_load_layout, null)
            with(contentView) {
                if (describle != null) {
                    notice.text = describle
                    notice.visibility = View.GONE
                }
                if (describle == "") {
                    notice.visibility = View.GONE
                }
//                //动画
                //其他设置
                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE) //设置没有标题
                val dialogWindow = dialog.window
                dialogWindow!!.setContentView(contentView)//设置内容
                dialog.setCanceledOnTouchOutside(isOutTouch)//设置Dialog以外是否可触摸
                return dialog
            }
        }
    }
}
